package com.limedia.explorer.transmission;

public class RTMPTransmissionJNI {

	private static final String TAG = RTMPTransmissionJNI.class.getSimpleName();
	private static final Object lockObject = new Object();
	private static RTMPTransmissionJNI mInstance = null;
	
	static {
		System.loadLibrary("rtmp");
	}
	
	private native int nativeInit(String path);
	private native void nativeWriteSPSPPS(byte[] pps, int ppsSize, byte[] sps, int spsSize);
	private native void nativeWriteFrame(byte[] data, int size, int keyFrame, int timeStamp);
	private native void nativeDeinit();
	
	private RTMPTransmissionJNI() {
		super();
	}
	
	public synchronized static RTMPTransmissionJNI getInstance() {
		if(null == mInstance) {
			mInstance = new RTMPTransmissionJNI();
		}
		return mInstance;
	}
	
	public int init(String path) {
		return nativeInit(path);
	} 
	
	public void writeSPSPPS(byte[] pps, int ppsSize, byte[] sps, int spsSize) {
		nativeWriteSPSPPS(pps, ppsSize, sps, spsSize);
	}
	
	public void writeFrame(byte[] data, int size, int keyFrame, int timeStamp) {
		nativeWriteFrame(data, size, keyFrame, timeStamp);
	}
	
	public void deinit() {
		nativeDeinit();
	}
}
